<?php
include_once 'Panel/UserModel.php';

class UserController extends UserModel {
	protected $_user;

	function __construct($__user_id=null){
		$this->_user  = UserModel::getUserByID($__user_id);	
	}
	
	public function indexAction($__user_id=null){
		$this->_user  = UserModel::getUserByID($__user_id);				
		return $this;
	}

	function byusernameAction($username=null){
		$this->_user  = UserModel::getUserByUseName($username);
	}

	function byStanowiskoAction($stanowisko=null){
		$this->_user  = UserModel::getUserByStanowisko($stanowisko);
	}
	
	function byuseremailAction($email=null){
		$this->_user  = UserModel::getUserByUseEmail($email);
	}
	
	public function __get($__column){
		switch($__column){
			case 'all':
				return $this->_user;
				break;
			default:	
				if (is_array($this->_user)){				
					if(array_key_exists($__column,$this->_user)){
						return($this->_user[$__column]);
					}else{
						return(false);
					}
				}else{
					return(false);
				}
		}		
	}
	
	public function __set($col,$val){
		$this->setUserData($col,$val);	
	}

}

?>